home *** CD-ROM | disk | FTP | other *** search
/ PC Direct 1998 August / PC Direct August 1998.iso / S / powerj / Product / hpp.z / WTRANSDR.HPP < prev    next >
Encoding:
C/C++ Source or Header  |  1997-11-25  |  7.8 KB  |  237 lines

  1. /*************************************************************************
  2.  *
  3.  * WODCBTransaction -- ODBC transaction interface.
  4.  *
  5.  *************************************************************************/
  6.  
  7. #ifndef _WTRANSDR_HPP_INCLUDED
  8. #define _WTRANSDR_HPP_INCLUDED
  9.  
  10. #ifndef _WREFOBJ_HPP_INCLUDED
  11. #include "wrefobj.hpp"
  12. #endif
  13. #ifndef _WTRANSAC_HPP_INCLUDED
  14. #include "wtransac.hpp"
  15. #endif
  16.  
  17. class WODBCDriver;
  18.  
  19. //
  20. // WODBCTransaction
  21. //
  22. // Specialization of WTransaction that knows how to talk to an ODBC
  23. // driver.
  24. //
  25.  
  26. class WCMCLASS WODBCTransaction : public WTransaction {
  27.  
  28.     WDeclareSubclass( WODBCTransaction, WTransaction );
  29.  
  30.     public:
  31.  
  32.         WODBCTransaction( WTransaction *proxy=NULL );
  33.  
  34.         virtual ~WODBCTransaction();
  35.  
  36.         /****************************************************************
  37.          * Properties
  38.          ****************************************************************/
  39.  
  40.         // ODBCDriver
  41.         //
  42.         //
  43.  
  44.         virtual WODBCDriver *GetODBCDriver() const;
  45.  
  46.         /***************************************************************
  47.          * Methods
  48.          ***************************************************************/
  49.  
  50.         /***************************************************************
  51.          * Overrides
  52.          ***************************************************************/
  53.  
  54.         WTAccessMode GetAccessMode() const;
  55.         WBool        SetAccessMode( WTAccessMode accessMode );
  56.  
  57.         WBool GetAutoCommit() const;
  58.         WBool SetAutoCommit( WBool autoCommit );
  59.  
  60.         WTBookmarkPersistence GetBookmarkPersistence() const;
  61.  
  62.         WBool GetConnected() const;
  63.  
  64.         WDWord GetConnectionHandle() const;
  65.         WBool  SetConnectionHandle( WDWord conn );
  66.  
  67.         WString GetConnectParams() const;
  68.         WBool   SetConnectParams( const WString & connectParams );
  69.  
  70.         WTCursorDriver GetCursorDriver() const;
  71.         WBool          SetCursorDriver( WTCursorDriver driv );
  72.  
  73.         WString GetDataSource() const;
  74.         WBool   SetDataSource( const WString & dataSource );
  75.  
  76.         WString GetDBMSName() const;
  77.         WBool   SetDBMSName( const WString & dbmsName );
  78.  
  79.         WBool GetDisplayErrorDialog() const;
  80.         WBool SetDisplayErrorDialog( WBool display );
  81.  
  82.         WBool GetDisplayWarningDialog() const;
  83.         WBool SetDisplayWarningDialog( WBool display );
  84.  
  85.         WDWord GetEnvironmentHandle() const;
  86.         WBool  SetEnvironmentHandle( WDWord envHandle );
  87.  
  88.         WLong GetErrorCode( WLong *apiFunc = NULL ) const;
  89.  
  90.         WBool GetErrorInfo( WString *errorMessage, WString *state = NULL,
  91.                             WLong *nativeErrorCode = NULL ) const;
  92.  
  93.         WDataErrorArray GetErrorList() const;
  94.  
  95.         WTFetchDirection GetFetchDirection() const;
  96.  
  97.         WTFileUsage GetFileUsage() const;
  98.  
  99.         WTIsolationLevel GetIsolationLevel() const;
  100.         WBool            SetIsolationLevel( WTIsolationLevel level );
  101.  
  102.         WString GetLoginID() const;
  103.         WBool   SetLoginID( const WString & lid );
  104.  
  105.         WString GetLoginPassword() const;
  106.         WBool   SetLoginPassword( const WString & pwd );
  107.  
  108.         WTLoginPrompt GetLoginPrompt() const;
  109.         WBool         SetLoginPrompt( WTLoginPrompt prompt );
  110.  
  111.         WLong GetMaxOptionIndex() const;
  112.  
  113.         WLong GetNumericOption( WTOptionID id ) const;
  114.         WBool SetNumericOption( WTOptionID id, const WLong value );
  115.  
  116.         WString GetPassword() const;
  117.         WBool   SetPassword( const WString & password );
  118.  
  119.         WTQualifierLocation GetQualifierLocation() const;
  120.  
  121.         WString GetQualifierSeparator() const;
  122.  
  123.         WString GetServerName() const;
  124.         WBool   SetServerName( const WString & server );
  125.  
  126.         WTStaticSensitivity GetStaticSensitivity() const;
  127.  
  128.         WString GetStringOption( WTOptionID id ) const;
  129.         WBool   SetStringOption( WTOptionID id, const WString & value );
  130.  
  131.         WTCursorTypes GetSupportedCursorTypes() const;
  132.  
  133.         WTUpdateTypes GetSupportedUpdateTypes() const;
  134.  
  135.         WBool GetTraceToLog() const;
  136.         WBool SetTraceToLog( WBool on );
  137.  
  138.         WString GetUserid() const;
  139.         WBool   SetUserid( const WString & userid );
  140.  
  141.         WTCursorCommitBehavior GetCursorCommitBehavior() const;
  142.  
  143.         WTCursorRollbackBehavior GetCursorRollbackBehavior() const;
  144.  
  145.         WBool Commit();
  146.  
  147.         WBool Connect( WWindow *parent=NULL, WBool doConnect=TRUE );
  148.  
  149.         WBool Create( WDWord envHandle=0, WDWord connHandle=0 );
  150.         WBool Create( const WString & dbmsName );
  151.  
  152.         WBool Destroy();
  153.  
  154.         WBool Disconnect( WBool doDisconnect=TRUE );
  155.  
  156.         WBool FetchErrors( WLong, WLong );
  157.  
  158.         WBool GetDataSourceInfo( WString *name, WString *description,
  159.                                  WBool getFirst = FALSE ) const;
  160.  
  161.         WBool GetOptionInfo( WTOptionID & id, WString & name,
  162.                              WBool *isString = NULL,
  163.                              WLong index = -1 ) const;
  164.  
  165.         WBool List( WQuery & query, WTListType type, const WTListSource *source,
  166.                     const WTListSource *source2 = NULL,
  167.                     WDWord flags = WTF_ENSURE_VALIDITY );
  168.  
  169.         WBool Rollback();
  170.  
  171.     protected:
  172.  
  173.         /****************************************************************
  174.          * Internal
  175.          ****************************************************************/
  176.  
  177.         WBool CheckODBCRetCode( RETCODE rc, WLong func ) const;
  178.  
  179.         WBool BuildConnectStr();
  180.         WBool SplitConnectStr( const WString & newStr );
  181.  
  182.         WBool IsODBCOption( WTOptionID id ) const;
  183.  
  184.         /****************************************************************
  185.          * Property Data
  186.          ****************************************************************/
  187.  
  188.         WBool                       _connected;
  189.         WString                     _connectParams;
  190.         HDBC                        _connHandle;
  191.         WBool                       _freeConn;
  192.         WString                     _dataSource;
  193.         HENV                        _envHandle;
  194.         WBool                       _freeEnv;
  195.         WTLoginPrompt               _loginPrompt;
  196.         WODBCDriver *               _driver;
  197.         WString                     _password;
  198.         WString                     _userid;
  199.         WDWord                      _bookmarks;
  200.         WDWord                      _fetchDirection;
  201.         WDWord                      _staticSensitivity;
  202.         WDWord                      _cursorTypes;
  203.         WDWord                      _cursorDriver;
  204.         WLong                       _qualifierLocation;
  205.         WString                     _qualifierSeparator;
  206.         WLong                       _fileUsage;
  207.         WDWord                      _updateType;
  208.         WString                     _loginID;
  209.         WString                     _loginPassword;
  210.         WString                     _serverName;
  211.         WTCursorCommitBehavior      _cursorCommitBehavior;
  212.         WTCursorRollbackBehavior    _cursorRollbackBehavior;
  213.  
  214.  
  215.         /****************************************************************
  216.          * Internal Data
  217.          ****************************************************************/
  218.  
  219.         WBool                   _fetchedError;
  220.         WString                 _connStr;       // ODBC connection string
  221.         WLong                   _lastCode;      // RC of the last ODBC call
  222.         WLong                   _lastFunc;
  223.         WDataErrorArray         _errorList;
  224.         WBool                   _displayErrors;
  225.         WBool                   _displayWarnings;
  226.  
  227.  
  228.         WTransaction *          _proxy;
  229.  
  230.         static const WConstantString    _useridKW;      // connection string keywords
  231.         static const WConstantString    _passwordKW;
  232.         static const WConstantString    _dataSourceKW;
  233.  
  234. };
  235.  
  236. #endif
  237.